from function import *
from config import *
import methods
import time
import pandas as pd

def main():
    wandb.init(name=time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime(time.time())))
    optimizer = getattr(methods, wandb.config.optimizer)(fName, wandb.config)
    z_history,x1_history,x2_history = optimizer.minimize()
    plotAll(fName,np.array(x1_history), np.array(x2_history))
    # df = pd.read_csv("a.csv")
    # df1 = pd.DataFrame(index=False,data=[wandb.config.optimizer,z_history,x1_history,x2_history])
    # df.append(df1).to_csv("a.csv")

if __name__ == '__main__':
    sweep_id = wandb.sweep(sweep=sweep_configuration, project="优化算法plotly")
    wandb.agent(sweep_id, function=main, count=1)
